import request from "@/utils/request";
const defaultApi = (apiName) => {
    return {
        list: (params) => request.get(`/${apiName}/list`, { params }),
        page: (params) => request.get(`/${apiName}`, { params }),
        read: (id) => request.get(`/${apiName}/` + id),
        create: (id, data) => request.post(`/${apiName}`, data),
        update: (id, data) => request.put(`/${apiName}/` + id, { ...data, create_time: undefined, id: undefined }),
        delete: (id) => request.delete(`/${apiName}/` + id)
    }
}
export const http = {
    admin: defaultApi('admin'),
    consume: defaultApi('consume'),
    message: defaultApi('message'),
  role: defaultApi('role'),
    recharge: defaultApi('recharge'),
  user: defaultApi('user'),
    product: {
        ...defaultApi('product'),
        createList: (data) => request.post('/product/createList', data),
    },
    login: (data) => request.post('/user/login', data),
  messageProduct: defaultApi('messageProduct'),
    member: defaultApi('member'),
}
